home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / pmode / 386p_200 / 386video.inc < prev    next >
Encoding:
Text File  |  1994-11-07  |  9.9 KB  |  242 lines

  1. include 386sys.inc
  2.  
  3. extrn _DispX:Dword    ; display size
  4. extrn _DispY:Dword    ; N.B. this is the VIEWABLE display size
  5.                       ;      the display page may be wider
  6.                       ;      but this is _PageFlip0/1 stuff
  7.                       ;      "you don't see it"
  8.  
  9. extrn _VDispX:Dword     ; display window start inside screen buffer
  10. extrn _VDispY:Dword     ; this is the upper left corner of the portion
  11.                         ; of the screen buffer viewable on the display
  12.                         ; at the next _PageFlip
  13.  
  14. extrn _ScrX:Dword    ; screen buffer size
  15. extrn _ScrY:Dword    ; the screen buffer is _ScrX*_ScrY bytes wide
  16.  
  17. extrn _ScrSD:Dword   ; screen size in dwords, useful to some XGE routines
  18.  
  19. extrn _XSquare:Dword ;  _XSquare/_YSquare == pixel aspect ratio
  20. extrn _YSquare:Dword ;
  21.  
  22. extrn _XVDTotRam:Dword ; availabe ram on vidoe board in 64k units
  23. extrn _XVDExternal:byte    ; tried to load external driver
  24. extrn _XVDGoodDriver:byte  ; found XVD marker at start of external driver
  25. extrn _XVDBGood:byte       ; check for external driver's bios OK
  26. extrn _XVDCGood:byte       ; check for external driver's chipset OK
  27.  
  28. extrn _ScrBase :dword ; base offset of NEXT screen buffer
  29.                       ; displayed by _PageFlip
  30.                       ; this MAY change after a _PageFlip
  31.  
  32. ; table of line start offsets (initialized by _SetXVDMode)
  33. extrn _RowStart   :dword
  34.  
  35. extrn _SetXVDMode: dword
  36.        ; Initialize graphics mode
  37.        ; according to what is set into
  38.        ; _DispX,DispY  (screen resolution)
  39.        ; _ScrX,_ScrY   (screen buffer size)
  40.        ; Those variables are set to the nearest values supported
  41.        ; or _Exit is called if it is not possible to do that
  42.        ; _VDispX,VDispY are set to zero
  43.        ; _ScrSD , _RowStart, _ScrBase are initialized
  44.  
  45. extrn _RestoreTextMode: dword
  46.        ; Restores default 80x25 color text mode & shuts down video driver
  47.        ; (called automatically by _Exit code
  48.        
  49. extrn _DisplayStart: dword
  50.        ; EAX= x_position 
  51.        ; EBX = y_position 
  52.        ; Sets the new starting position (_VDispX,_VDispY)
  53.        ; of the viewable window inside the display buffer.
  54.        ; USE THIS to change _VDispX,_VDispY because the actual
  55.        ; display start change may need some processing
  56.        
  57.        ; PAGEFLIP ROUTINES
  58. extrn _PageFlip0: dword
  59. extrn _PageFlip1: dword
  60.        ; _PageFlipping routines ... here comes the lightning
  61.        ; they set the "old" active page (screen buffer)
  62.        ; (the one referenced thru _ScrBase)
  63.        ; as the new viewable page (display page)
  64.        ; they can actually copy the bitmap or just change a set of
  65.        ; display start registers, you don't need to know exactly
  66.        ; how they work, just reload the "screen base" offset
  67.        ; from _ScrBase before doing other things.
  68.        ; every driver MUST support three different methods
  69.        ; a) _PageFlip0 (BRUTE FORCE), copies the whole bitmap into _Scrbase
  70.        ;    to "viewable" ram (copying it or changing display start)
  71.        ;    Useful if your card is fast and/or can map lots of video ram
  72.        ;    as directly addressable ram (i.e. a VL-BUS Tseng ET-4000w32).
  73.        ;    USING THIS METHOD, ALL the screen buffer MUST BE "COMPOSED"
  74.        ;    before calling this.
  75.        ;    
  76.        ; b) _PageFlip1 (TOUCHMAP), copy only the pixels "flagged" 
  77.        ;    into the internal touchmap structures.
  78.        ;    Useful when you "know ahead" what portions of bitmap are changed
  79.        ;    and your video ram access is not very fast.
  80.        ;
  81.        
  82. extrn _TouchBlock: dword
  83.         ; eax,edx == (xstart,ystart)
  84.         ; ecx = width in nudgets (4 adiacent pixels blocks)
  85.         ; ebx = height in pixels
  86.         ; marks a portion of the viewable window as "touched"
  87.         ; (modified between two pageflips)
  88.         ; so these pixels will be copied to screen if _PageFLip1
  89.         ; is called at the next pageflip
  90.         
  91. extrn _CompFlip:dword
  92.         ; Compiles a pageflipping mask
  93.         ; (useful when the portions you have to "refresh" are nearly always
  94.         ;  the same)
  95.         ; to do this you have to pass the base and top pointers of the heap
  96.         ; you want to store the pageflip data on.
  97.         ; BEFORE:
  98.         ; Use _TouchBlock to set the current touchmap as you want
  99.         ; the "compiled pageflipper" will act.
  100.         ; IN:
  101.         ; eax = allocation heap base , edx = allocation heap top
  102.         ; OUT:
  103.         ; IF CARRY CLEAR THEN
  104.         ;    eax = NEW allocation heap base, edx = NEW allocation heap top
  105.         ;    edi = pointer to custom pageflipping data/code
  106.         ; ELSE NOTHING HAPPENED
  107.         ;
  108.         ; example:
  109.         ;           <touch pixels here and there using _TouchBlock>
  110.         ;           ; now store store custom flip data on low memory
  111.         ;           mov eax,_LoMemBase
  112.         ;           mov edx,_LoMemTop
  113.         ;           call _CompFlip
  114.         ;           mov _LoMemBase,eax
  115.         ;           mov _LoMemTop,edx
  116.         ;           mov MyCustomFlipper,edi
  117.         
  118. extrn _CustomFlip:dword
  119.         ; Executes a custom pageflipping as compiled from _CompFlip
  120.         ; But doesn't modify the current touchmaps
  121.         ; IN:
  122.         ;    eax= pointer to custom pageflipping data/code      
  123.         
  124. ; AND NOW SOME EXPLANATIONS ABOUT HOW TO FLIP PAGES
  125. ; (just to let you understand how it currently works
  126. ;  and how it will evolve)
  127. ; (N.B. The current 386video module supports only
  128. ;       video mapping 0 and 1)
  129. ;
  130. ; video mapping:  0 = buffer on system ram, single display page
  131. ;                 1 = buffer on system ram, multiple display pages
  132. ;                 2 = buffer on vram,       single display page
  133. ;                 3 = buffer on vram,       multiple display pages
  134. ;
  135. ; page-flip:  0 = _PageFlip0
  136. ;             1 = _PageFlip1
  137.  
  138. ; video mapping    page-flip
  139.  
  140. ;                           SINGLE VIDEO PAGE ------------------------------
  141. ;            0          0   ; COPY from the _ScrBase buffer to display page
  142. ;                           ; maybe using the ram to vram blitter if present
  143. ;                           ; (no other way)
  144. ;            0          1   ; COPY only the "touched" pixels to display page
  145. ;                           ; (no other way)
  146.  
  147. ;                           MULTIPLE VIDEO PAGES ---------------------------
  148. ;            1          0   ; COPY from _ScrBase to NEW display page
  149. ;                           ; THEN CHANGE DISPLAY PAGE (reducing jitter)
  150. ;            1          1   ; IF NO FAST_BLITTING_HARDWARE
  151. ;                           ;    COPY only the "touched" pixels to display page
  152. ;                           ; ELSE IF FAST_VRAM_BLITTER PRESENT
  153. ;                           ;    BLIT the displayed page to the "new" one
  154. ;                           ;    COPY the differences to the new one
  155. ;                           ;    (reducing jitter)
  156. ;                           ; ELSE IF FAST_RAM_TO_VRAM_BLITTER PRESENT
  157. ;                           ;    BLIT "raw" from _ScrBase to new page
  158. ;                           ;    CHANGE DISPLAY PAGE
  159. ;                           ; ENDIF
  160.  
  161. ;                           VRAM MAPPING, SINGLE PAGE ----------------------
  162. ;            2          0   ; COPY from the _ScrBase buffer to display page
  163. ;            2          1   ; COPY only the "touched" pixels to display page
  164.  
  165. ;                           VRAM MAPPING, MULTIPLE PAGES -------------------
  166. ;            3          0   ; CHANGE DISPLAY PAGE, CHANGE _ScrBase
  167. ;            3          1   ; COPY only the "touched" pixels to display page
  168.  
  169. ; AS YOU CAN GUESS _PageFlip1 usually is faster than _PageFlip0
  170. ; but is not always true, before calling _SetXVDMode set _XVDMappings
  171. ; as you'd like it to be, then check what the driver can do
  172. ; and use the best "page composition" method that better suits
  173. ; the available driver.
  174.  
  175. ; "static" color indexes
  176. ;  Windows static colors, i use these because i wanted a wide "standard set"
  177. ;  of colors for loadable modules usage and because i plan to add
  178. ;  a "connect to WinG" interface if there is no other driver present.
  179.  
  180. BLACK=0
  181. DARK_RED=1
  182. DARK_GREEN=2
  183. DARK_YELLOW=3
  184. DARK_BLUE=4
  185. DARK_MAGENTA=5
  186. DARK_CYAN=6
  187. GRAY=7
  188. MONEY_GREEN=8
  189. SKY_BLUE=9
  190.  
  191. CREAM=246
  192. MEDIUM_GRAY=247
  193. GRAY=248
  194. RED=249
  195. GREEN=250
  196. YELLOW=251
  197. BLUE=252
  198. MAGENTA=253
  199. CYAN=254
  200. WHITE=255
  201.  
  202. ; "static text colors", these are set on a per application basis
  203. ; to define the standard "shaded" character set.
  204. BRIGHT1_TEXT=10   ; most saturated
  205. BRIGHT6_TEXT=15   ; least saturated , "bright background"
  206.  
  207. DARK1_TEXT=240 ; most saturated
  208. DARK6_TEXT=245 ; least saturated, "dark background"
  209. ;----------------------------------------------------------------------------
  210. ; _Set1Pal    in:     al = palette entry to set
  211. ;                    edx = bit 0..7   red
  212. ;                          bit 8..15  green
  213. ;                          bit 16..23 blue 
  214. ;                          bit 24..31 non utilizzati
  215. ;                    N.B. RGB entries have FULL 8BIT RESOLUTION!!!!
  216. ;                         (vga has 6 bits for color entry)
  217. ;
  218. extrn  _Set1Pal:dword
  219.  
  220. ;----------------------------------------------------------------------------
  221. ; _Get1Pal    in:     al = palette entry to set
  222. ;             out:
  223. ;                    edx = bit 0..7   red
  224. ;                          bit 8..15  green
  225. ;                          bit 16..23 blue
  226. ;                          bit 24..31 non utilizzati
  227. ;                    N.B. RGB entries have FULL 8BIT RESOLUTION!!!!
  228. ;                         (vga has 6 bits for color entry)
  229. ;
  230.  
  231. extrn  _Get1Pal:dword
  232. ; reads palette entry AL and stores it into EDX
  233.  
  234. ;----------------------------------------------------------------------------
  235. ; _Set256Pal  esi=pointer to a table of 256 palette entries
  236. ;                 every palette entry is made of three bytes
  237. ;                 for Red Green and Blue 24BIT PALETTE values
  238. ;
  239. extrn  _Set256Pal:dword
  240.                 
  241.  
  242.